<div class="info-input">
    <form method="post" id="login-form">
        {{csrf_field()}}
        <h2 title="LOGIN">LOGIN</h2>
        <dl>
            <dt>LOGIN ID</dt>
            <dd><input name="username" id="username" type="text" class="box-txt"></dd>
            <dt>PASSWORD</dt>
            <dd><input name="password" id="password" type="password" class="box-txt">
                <p class="p-t10">
                    <span class="check-box">
                        <input name="checkbox"   type="checkbox" id="checkbox1" /><label for="checkbox1">记住账户和密码</label>
                    </span>
                </p></dd>
        </dl>
        <button class="btnA" onclick="SetPwdAndChk()" type="button" >LOGIN</button>
    </form>
   </div>
</div>
<script>
    // 记住密码操作 保存到localStorage
    $(function () {
        var loUser = localStorage.getItem("user") || "";
        var loPass = localStorage.getItem("pass") || "";
        document.getElementById("username").value = loUser;
        document.getElementById("password").value = loPass;
        if(loUser !== "" && loPass !== ""){
            document.getElementById("checkbox1").checked = true;
        }
    });

    function SetPwdAndChk(){
        var checkDark =document.getElementById("checkbox1");
        var user = $("#username").val();
        var pass = $("#password").val();
        if(checkDark.checked){
            localStorage.setItem("user",user);
            localStorage.setItem("pass",pass);
        }else{
            localStorage.setItem("user","");
            localStorage.setItem("pass","");
        }
        $("#login-form").submit();
    }
</script>
